
<script>
//var domainInfo=[{name:'www.a.com'},{name:'www.a.com'},{name:'www.a.com'}]
<?php
 //$domainInfo="[{id:'0',name:'www.a.com'},{id:'1',name:'www.a.com'},{id:'2',name:'www.a.com'}]"
 ?>
var domainInfo=<?php echo $domain ?>;
domainInfo=eval(domainInfo);
//alert(domainInfo);
$(document).ready(function(){
	$("#domain").autocomplete(domainInfo, {
		minChars: 0,
		mustMatch: true,
		width: 350,
		matchContains: true,
		selectFirst: true,
		cacheLength: 1,
		autoFill: false,
		matchCase: true,
		formatItem: function(row, i, max) {
			return i + "/" + max + ": " + row.name;
		},
		formatMatch: function(row, i, max) {
			return  row.name ;
		},
		formatResult: function(row) {
			return row.name;
		}
	}).result(function(event, data, formatted) {
		if ($(this).val() == "") {
			$(this).val("");
			$("#domain").html(data['name']);
		}else{
			$("#domain").html("");
		}
	});	
});	
</script>
<body>
<?php 
//echo validation_errors();
 ?>

<?php echo form_open('urlform'); ?>
<p>请输入您要缩短的长网址</p>
<p><input name="purposeUrl" type="text" value="<?php echo set_value('purposeUrl'); ?>" size="50"/></p>
<?php echo form_error('purposeUrl'); ?>
<p>请选择您拥有的域名</p>
<p><input id="domain" name="domain" type="text" value="<?php echo set_value('purposeUrl'); ?>" size="50"/>/<input type="text" name="shorturl" value="<?php echo set_value('shorturl'); ?>"  /></p>
<?php echo form_error('domain'); ?>
<div style="width=100%"><input type="submit" value="Submit" /></div>
<?php echo form_error('shorturl'); ?>
</form>

</body>
</html>
